package com.wpp.mq.rabbitmqsqmple.factory;

import com.rabbitmq.client.ConnectionFactory;
import com.wpp.mq.rabbitmqsqmple.common.Constant;

/**
 * @description:
 * @author: WangPengPeng
 * @create: 2021-11-28 21:31
 **/
public class MyConnectionFactoryBuilder {

    public  static ConnectionFactory buildConnection () {
        ConnectionFactory factory = new ConnectionFactory();
        //设置服务器主机名或IP地址
        factory.setHost(Constant.HOST_ALIAS);
        // 设置Erlang的虚拟主机名称
        factory.setVirtualHost(Constant.VIRTUAL_HOST);
        // 设置用户名
        factory.setUsername(Constant.USER_NAME);
        // 设置密码
        factory.setPassword(Constant.PASSWORD);
        // 设置客户端与服务器的通信端口，默认值为5672
        factory.setPort(Constant.PORT);
        return factory;
    }
}
